#!/usr/bin/env python3

import asyncio
import json
import sys
import signal
import secrets
import time
from websockets.sync.client import connect

publish = {
        "data":{'msg':"来自服务器的推送"},
        "api_token":"liqing",
        "type":"publish"
    }

def signal_handler(signal, frame):
    sys.exit(0)

def hello():
    with connect("ws://47.104.233.79:8765") as websocket:
        websocket.send(json.dumps(publish))
if __name__ == "__main__":
    signal.signal(signal.SIGINT, signal_handler)
    hello()